package com.itheima.zuoye2.zy1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test {
    public static void PrintTheCollection(Collection c) {
        System.out.println("=======================");
        Iterator it = c.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }
    public  static void FindCollection(Collection <String>c) {
        System.out.println("=======================");
        for (String s : c) {
            if (s.length() < 10) {
                System.out.println(s);
           }
       }

    }
    public static void FilterTheCollection(Collection <String>c) {
        System.out.println("=======================");
        Iterator it = c.iterator();
        while (it.hasNext()){
            String s = (String) it.next();
//            字符串中包含java
            if (s.contains("Java")){
                System.out.println(s);
            }
        }
    }
    public static void FilterTheCollection2(Collection <String>c) {
        Iterator it = c.iterator();
        while (it.hasNext()){
            String s = (String) it.next();
//            字符串中包含Oracle
            if (s.contains("Oracle")){
                it.remove();
            }
        }
        PrintTheCollection(c);
    }

    public static void main(String[] args) {
        Collection <String>c = new ArrayList<>();
        c.add("JavaEE企业级开发指南");
        c.add("Java架构师之路");
        c.add("Oracle高级编程");
        c.add("Mysql从入门到精通");
        PrintTheCollection(c);
        FindCollection(c);
        FilterTheCollection(c);
        FilterTheCollection2(c);



    }
}
